package monitori_di_hoare;

class Sender extends Thread {
	int id;
	int seed;
	BufferLimitato<Integer> bl;

	public Sender(int id, int seed, BufferLimitato<Integer> bl) {
		this.id = id;
		this.seed = seed;
		this.bl = bl;
	}

	public void run() {
		while (true) {
			System.out.println("Sender#" + id + " invia messaggio# " + seed);
			bl.put(new Integer(seed)); // oppure: bl.put( seed ); //autoboxing
										// dei tipi di base
			seed++;
			try {
				sleep((int) (Math.random() * 500));
			} catch (InterruptedException e) {
			}
		}
	}
}// Producer
